#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

const int N = 100005;
int n,k,L,R,tot,m,opt;
ll a[N];

struct node{
    int l,r;
    ll sum,max;
    node * ls , * rs;
}tree[4 * N];

inline node * create(){return &tree[++tot];}

inline void pushup(node * cur){cur->sum = cur->ls->sum + cur->rs->sum , cur->max = std::max(cur->ls->max,cur->rs->max);}

inline void build(node * cur,int l,int r){
    cur->l = l , cur->r = r;
    if(l == r){
        cur->sum = cur->max = a[l];
        return;
    } else {
        int mid = (l + r) >> 1;
        cur->ls = create() , cur->rs = create();
        build(cur->ls,l,mid) , build(cur->rs,mid+1,r);
        pushup(cur);
        return;
    }
}

inline ll Query(node * cur){
    if(L <= cur->l && cur->r <= R) return cur->sum;
    if(cur->r < L || R < cur->l) return 0;
    return Query(cur->ls) + Query(cur->rs);
}

inline void Update(node * cur){
    if(cur->max <= 1) return;
    if(cur->l == cur->r && cur->l >= L && cur->r <= R){
        cur->sum = cur->max = (ll)std::sqrt(cur->sum);
        return;
    } else {
        if(cur->r < L || R < cur->l) return;
        Update(cur->ls) , Update(cur->rs);
        pushup(cur);
        return;
    }
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> n;
    rep(i,1,n) cin >> a[i];
    node * root = create();
    build(root,1,n);
    cin >> m;
    rep(i,1,m){
        cin >> opt >> L >> R;
        if(L > R) std::swap(L,R);
        if(opt) cout << Query(root) << "\n";
        else Update(root);
    }
    return 0;
}